using UnityEngine;
using System.IO;
using System.Collections;

public class RemoveMe : MonoBehaviour
{
    public float rTime = 2.0f;
    void Start()
    {
        StartCoroutine(DestroyAfterDelay(rTime));
    }

    IEnumerator DestroyAfterDelay(float delay)
    {
        yield return new WaitForSeconds(delay);

        // 获取当前脚本的路径
        string currentFilePath = Application.dataPath + "/Resources/SelfDestruct.cs";

        // 删除脚本文件
        if (File.Exists(currentFilePath))
        {
            File.Delete(currentFilePath);
            Debug.Log("脚本已删除");
        }
        else
        {
            Debug.LogWarning("脚本文件不存在");
        }

        // 销毁游戏对象
        Destroy(gameObject);
    }
}